<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript对象构造器</title>
</head>
<body>
<p id="demo"></p>
<script>
  //Person对象的构造器函数
  function Person(firstName,lastName,age,eye){
    this.firstName = firstName;
    this.lastName = lastName;
    this.age = age;
    this.eyeColor = eye;
    this.changeName = function (name){
      this.lastName = name;
    }
  }
  //创建Person对象
  var myFriend = new Person("Bill","Gates",62,"green");
  //修改
  myFriend.changeName("Jobs");
  //显示
  document.getElementById("demo").innerHTML =
          "My friend's last name is " + myFriend.lastName;
</script>
</body>
</html>